import { createApp } from "vue";
import pinia from "./stores";
import ElementPlus from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import "element-plus/dist/index.css";
import App from "./App.vue";
import router from "./router";
import "./styles/index.scss";
import ElSvg from "./components/SvgIcon/ElSvg";
import "./permission";

import Category from "./components/Category/index.vue";
import { useUserInfoStore } from "@/stores/userInfo";

import "./mockServer/mockServer";

import ECharts from "vue-echarts";
import { use } from "echarts/core";

import { CanvasRenderer } from "echarts/renderers";
import { BarChart } from "echarts/charts";
import { GridComponent, TooltipComponent } from "echarts/components";

use([CanvasRenderer, BarChart, GridComponent, TooltipComponent]);

const app = createApp(App);

app.component("v-chart", ECharts);

app.directive("hidden", {
  mounted(element, binding) {
    if (!useUserInfoStore().buttons.includes(binding.value)) {
      element.remove();
    }
  },
});

app.component("Category", Category);

ElSvg(app);
app
  .use(pinia)
  .use(router)
  .use(ElementPlus, {
    locale: zhCn,
  })
  .mount("#app");
